﻿@inject IWebHostEnvironment environment
@{
    var pageMeta = PageMeta.Parse(Context.Request.Path);
    var versionMenu = VersionMenu.GetMenu(pageMeta.Lang);
    var activeVersion = pageMeta.Version.ConvertToString();    
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@ViewBag.Title - Rapid SCADA</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
    @RenderSection("Styles", required: false)
    @RenderSection("Scripts", required: false)
</head>
<body>
    @if (!environment.IsDevelopment())
    {
        <partial name="_Counter" />
    }
    <nav class="navbar sticky-top navbar-expand-lg navbar-dark bg-dark">
        <div class="container-xxl">
            <a class="navbar-brand mb-0 h1" asp-page="/Index">Rapid SCADA Docs</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#divNavbarContent">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div id="divNavbarContent" class="collapse navbar-collapse">
                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                    @if (versionMenu.Count > 0)
                    {
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">@activeVersion</a>
                            <ul class="dropdown-menu dropdown-menu-dark">
                                @foreach (var item in versionMenu)
                                {
                                    var itemClass = item.Text == activeVersion ? "active" : "";
                                    <li><a class="dropdown-item @itemClass" href="@Url.Content(item.Url.PrependTilde())">@item.Text</a></li>
                                }
                            </ul>
                        </li>
                        <li class="nav-item d-lg-none">
                            <a class="nav-link" href="#" data-bs-toggle="offcanvas" data-bs-target="#divToc">Table of contents</a>
                        </li>
                    }
                </ul>
                <partial name="_Search" />
                @*<form class="d-flex" role="search">
                    <input class="form-control me-2" type="search" placeholder="Search">
                    <button class="btn btn-outline-light" type="submit">Search</button>
                </form>*@
            </div>
        </div>
    </nav>

    <div id="divLayout" class="container-xxl mt-3">
        @RenderBody()
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
</body>
</html>
